package com.michael.service;

import com.michael.assist.anno.DoLog;
import com.michael.common.error.code.BizCode;
import com.michael.common.error.exception.BizException;
import com.michael.integration.cache.CacheIntegration;
import com.michael.integration.dao.BlogDao;
import com.michael.integration.dao.MainDao;
import com.michael.integration.entity.BlogEntity;
import com.michael.service.bizReq.HomeIndexBizReq;
import com.michael.service.bizRes.HomeIndexBizRes;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;

@Service
@Slf4j
public class HomeService {

    @Autowired
    private CacheIntegration cacheIntegration;

    @Autowired
    private MainDao mainDao;

    @Autowired
    private BlogDao blogDao;

    @DoLog
    public HomeIndexBizRes index(HomeIndexBizReq bizReq) throws BizException {
        if(ObjectUtils.isEmpty(bizReq)){
            throw BizCode.SYS_FATAL_ERR.getException();
        }
        HomeIndexBizRes bizRes = new HomeIndexBizRes();
        BlogEntity entity = blogDao.queryById(1);
        bizRes.setMessage(bizReq.getMessage()+" blog:"+entity);
        return bizRes;
    }
}
